package com.hlingsoft.kkh;

import com.hlingsoft.kkh.action.BaseAction;
import com.hlingsoft.kkh.action.Student;
import com.hlingsoft.kkh.dao.ImageDao;
import com.hlingsoft.kkh.util.Common;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import java.text.Collator;
import java.util.Date;
import java.util.*;

/**
 * Created by selbylei on 2015/4/12.
 */


@Controller
public class Test extends BaseAction {

    @Autowired
    private static ImageDao imageDao;

    private static int fab(int index) {
        if (index == 1 || index == 2) {
            return 1;
        } else {
            return fab(index - 1) + fab(index - 2);
        }
    }


    public static void main(String[] args) {
//        System.out.println(fab(3));
//    //        System.out.println(getHotList(new Date()));
//        Date now = new Date();
//        System.out.println(now);
//        System.out.println(Common.transferLongToDate(1428646350));
//        System.out.println(Common.transferLongToDate(1428646401));
//
//         String json = "[1405312097000,1405312098000]";
//
//        JSONArray jsonArray = JSONArray.fromObject(json);
//        long[] tokeTimeArray = (long[]) JSONArray.toArray(jsonArray, long.class);
//        for (long l:tokeTimeArray){
//            System.out.println(Common.transferLongToDate(l/1000));
//        }
//
//
//        List<String> list = new ArrayList();
//        list.add("刘媛媛");
//        list.add("王硕");
//        list.add("李明");
//        list.add("刘迪");
//        list.add("刘布");
//
////升序
//        Collections.sort(list, Collator.getInstance(java.util.Locale.CHINA));//注意：是根据的汉字的拼音的字母排序的，而不是根据汉字一般的排序方法
//        for(int i=0;i<list.size();i++)
//        {
//            System.out.print(list.get(i));
//        }
//        System.out.println("");
//
////降序
//        Collections.reverse(list);//不指定排序规则时，也是按照字母的来排序的
//        for(int i=0;i<list.size();i++)
//        {
//            System.out.print(list.get(i));
//        }


//        public void testList () {

        List<Integer> list = new ArrayList<Integer>();
        list.add(1);
        list.add(2);
        list.add(4);
        list.add(1);
        list.add(2);
        list.add(5);
        list.add(1);
        List<Integer> listTemp = new ArrayList<Integer>();
        Iterator<Integer> it = list.iterator();
        while (it.hasNext()) {
            int a = it.next();
            if (listTemp.contains(a)) {
                it.remove();
            } else {
                listTemp.add(a);
            }
        }
        for (Integer i : list) {
            System.out.println(i);
        }
//        }

        Double distance = Common.getDistance(121.61090851, 31.2804184, 121.61053021, 31.27991678);
        System.out.println(distance / 1000);


        List<Student> stu = new ArrayList<Student>();
        stu.add(new Student("1", "yi"));
        stu.add(new Student("3", "san"));
        stu.add(new Student("3", "san"));
        stu.add(new Student("2", "er"));
        stu.add(new Student("2", "er"));
        //set集合保存的是引用不同地址的对象
        Set<Student> ts = new HashSet<Student>();
        ts.addAll(stu);

        for (Student student : ts) {
            System.out.println(student.getId() + "-" + student.getName());
        }

        String str = "1,2,3,112";

        String[] sourceStrArray = str.split(",");
        for (String string:sourceStrArray){
            long thelong = Long.valueOf(string);
            System.out.println(thelong);
        }

        String name = " ";
        System.out.println(name.replaceAll(" ","").equals(""));
        if((name.replace(" ","")!="")){
            System.out.println("selbylei");
        }
    }



}
